package cn.xd.itstack.springframework.beans;

import cn.xd.itstack.springframework.beans.PropertyValue;

import java.util.ArrayList;
import java.util.List;

/**
 * @Classname PropertyValues
 * @Description  属性集合包装类
 * @Date 2022/5/12 下午5:18
 * @Created by lvxiaodong
 */
public class PropertyValues {

    private List<PropertyValue> propertyValueList = new ArrayList<>();


    public void addPropertyValue(PropertyValue propertyValue) {
        propertyValueList.add(propertyValue);
    }

    public PropertyValue[] getPropertyValues() {
        return propertyValueList.toArray(new PropertyValue[0]);
    }

    public PropertyValue getPropertyValue(String propertyName) {
        for (PropertyValue propertyValue : propertyValueList) {
            if (propertyName.equals(propertyValue.getName())) {
                return propertyValue;
            }
        }
        return null;
    }
}
